home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / allchar.arc / ALLCHAR.PAS < prev   
Pascal/Delphi Source File  |  1985-10-12  |  23KB  |  951 lines

  1. Program Wordprocess;
  2. {$C-,V-,I-}
  3. type
  4.     TempString = string[80];
  5.  
  6. const
  7.   Digits: array[1..10] of char = ('1','2','3','4','5','6','7','8','9','0');
  8.   Positions: array[1..10] of integer = (1,11,21,31,41,47,55,63,69,74);
  9.   TabPositions: array[1..12] of integer = (6,11,16,21,26,31,36,41,46,51,56,61);
  10. var
  11.     Keynum, Keyset, Row, Column, I, MaxRow, ScreenRow, Temp1, Temp2, Temp3,
  12.          TopMargin, LeftMarg, RightMarg, Num, code, Style, Index, NumEnd,
  13.          InkeyHold, Position1, Position3, DiskSpace : integer;
  14.     Inkey, SecInkey, Choice, ch : char;
  15.     Words : array[1..500] of TempString;
  16.     Tabset : array[1..80] of boolean;
  17.     TextFile : Text;
  18.     TempWord, FileName, Test, Typeset : TempString;
  19.     Secnum, Row_One, Insertmode, Exit, result : boolean;
  20.     dosrec : record
  21.                ax,bx,cx,dx,bp,si,di,ds,es,flags : integer;
  22.              end;
  23.     OurDTA : array [ 1..43 ] of byte;    { Data Transfer Area buffer }
  24.     CurDTAseg,                           { DTA segment before execution }
  25.     CurDTAofs,                           { DTA offset    "        "     }
  26.     OurDTAseg,                           { DTA segment and offset set after }
  27.     OurDTAofs          : integer;        { start of program }
  28.     EPSONCHR : file;
  29.  
  30. procedure Window1;
  31. begin
  32.      Window(1,1,79,2);
  33. end;
  34.  
  35. procedure Window2;
  36. begin
  37.      Window(1,3,79,12);
  38. end;
  39.  
  40. procedure Window3;
  41. begin
  42.      Window(2,14,78,23);
  43. end;
  44.  
  45.  
  46.  
  47. procedure Keyset1;
  48. begin
  49.      Window3;
  50.      ClrScr;
  51.      GotoXY(1,1);
  52.      TextColor(15);
  53.      Write('Keys are as normal.');
  54.      GotoXY(60,1);
  55.      Write('Keyset 1');
  56.      Window2;
  57. end;
  58.  
  59. procedure Keyset2;
  60. begin
  61.      Window3;
  62.      ClrScr;
  63.      GotoXY(1,1);
  64.      TextColor(15);
  65.      Write('Key alterations highlighted.');
  66.      GotoXY(60,1);
  67.      Write('Keyset 2');
  68.      GotoXY(3,2);
  69.      Write('Unshifted:');
  70.      GotoXY(3,4);
  71.      TextColor(7);
  72.      Write('1 2 3 4 5 6 7 8 9 0 - =');
  73.      GotoXY(3,3);
  74.      TextColor(15);
  75.      Write('q r s t u v w x y p m }');
  76.      GotoXY(3,6);
  77.      TextColor(7);
  78.      Write('Q W E R T Y U I O P [ ]');
  79.      GotoXY(3,5);
  80.      TextColor(15);
  81.      Write('▒ ╖ Ñ ▓ ┤ ╣ ╡ ⌐ » ░ ¢ ¥');
  82.      GotoXY(3,8);
  83.      TextColor(7);
  84.      Write('A S D F G H J K L ; '' ` ');
  85.      GotoXY(3,7);
  86.      TextColor(15);
  87.      Write('í │ ñ ª º ¿ ¬ ½ ¼ { g á ');
  88.      GotoXY(3,10);
  89.      TextColor(7);
  90.      Write('\ Z X C V B N M , . /');
  91.      TextColor(15);
  92.      GotoXY(3,9);
  93.      Write('£ ║ ╕ ú ╢ ó « ¡ l n o');
  94.      GotoXY(40,2);
  95.      TextColor(15);
  96.      Write('Shifted:');
  97.      GotoXY(40,4);
  98.      TextColor(7);
  99.      Write('1 2 3 4 5 6 7 8 9 0 - =');
  100.      GotoXY(40,3);
  101.      TextColor(15);
  102.      Write('a Ç c d e ₧ f j h i ƒ k');
  103.      GotoXY(40,6);
  104.      TextColor(7);
  105.      Write('Q W E R T Y U I O P [ ]');
  106.      TextColor(15);
  107.      GotoXY(40,5);
  108.      Write('æ ù à Æ ö Ö ò ë Å É ╗ ╜');
  109.      GotoXY(40,8);
  110.      TextColor(7);
  111.      Write('A S D F G H J K L ; '' `');
  112.      GotoXY(40,7);
  113.      TextColor(15);
  114.      Write('ü ô ä å ç ê è ï î z b ╛');
  115.      GotoXY(40,10);
  116.      TextColor(7);
  117.      Write('\ Z X C V B N M , . /');
  118.      GotoXY(40,9);
  119.      TextColor(15);
  120.      Write('╝ Ü ÿ â û é Ä ì | ~');
  121.      Window2;
  122. end;
  123.  
  124.  
  125.  
  126. procedure Keyset3;
  127. begin
  128.      Window3;
  129.      ClrScr;
  130.      GotoXY(1,1);
  131.      TextColor(15);
  132.      Write('Key alterations highlighted.');
  133.      GotoXY(60,1);
  134.      Write('Keyset 3');
  135.      GotoXY(3,2);
  136.      Write('Unshifted:');
  137.      GotoXY(3,4);
  138.      TextColor(7);
  139.      Write('1 2 3 4 5 6 7 8 9 0 - =');
  140.      GotoXY(3,3);
  141.      TextColor(15);
  142.      Write('▒ ▓ │ ┤ ╡ ╢ ╖ ╕ ╣ ░ ¡ ╜');
  143.      GotoXY(3,6);
  144.      TextColor(7);
  145.      Write('Q W E R T Y U I O P [ ]');
  146.      GotoXY(3,5);
  147.      TextColor(15);
  148.      Write('± ≈ σ ≥ ⌠ ∙ ⌡ Θ ∩ ≡ █ ▌');
  149.      GotoXY(3,8);
  150.      TextColor(7);
  151.      Write('A S D F G H J K L ; '' `');
  152.      GotoXY(3,7);
  153.      TextColor(15);
  154.      Write('ß ≤ Σ µ τ Φ Ω δ ∞ ╗ º α');
  155.      GotoXY(3,10);
  156.      TextColor(7);
  157.      Write('\ Z X C V B N M , . /');
  158.      GotoXY(3,9);
  159.      TextColor(15);
  160.      Write('▄ · ° π ÷ Γ ε φ ¼ « »');
  161.      GotoXY(40,2);
  162.      TextColor(15);
  163.      Write('Shifted:');
  164.      GotoXY(40,4);
  165.      TextColor(7);
  166.      Write('1 2 3 4 5 6 7 8 9 0 - =');
  167.      GotoXY(40,3);
  168.      TextColor(15);
  169.      Write('í └ ú ñ Ñ ▐ ª ¬ ¿ ⌐ ▀ ½');
  170.      GotoXY(40,6);
  171.      TextColor(7);
  172.      Write('Q W E R T Y U I O P [ ]');
  173.      GotoXY(40,5);
  174.      TextColor(15);
  175.      Write('╤ ╫ ┼ ╥ ╘ ┘ ╒ ╔ ╧ ╨ √ ²');
  176.      GotoXY(40,8);
  177.      TextColor(7);
  178.      Write('A S D F G H J K L ; '' `');
  179.      GotoXY(40,7);
  180.      TextColor(15);
  181.      Write('┴ ╙ ─ ╞ ╟ ╚ ╩ ╦ ╠ ║ ó ■');
  182.      GotoXY(40,10);
  183.      TextColor(7);
  184.      Write('\ Z X C V B N M , . /');
  185.      GotoXY(40,9);
  186.      TextColor(15);
  187.      Write('ⁿ ┌ ╪ ├ ╓ ┬ ╬ ═ ╝ ╛ ┐');
  188.      Window2;
  189. end;
  190.  
  191.  
  192. procedure Keyset4;
  193. begin
  194.      Window3;
  195.      ClrScr;
  196.      GotoXY(1,1);
  197.      TextColor(15);
  198.      Write('Key alterations highlighted.');
  199.      GotoXY(60,1);
  200.      Write('Keyset 4');
  201.      GotoXY(3,2);
  202.      Write('Unshifted:');
  203.      GotoXY(3,4);
  204.      TextColor(7);
  205.      Write('Q W E R T Y U');
  206.      GotoXY(3,3);
  207.      TextColor(15);
  208.      Write(Chr(1),' ',Chr(2),' ',Chr(3),' ',Chr(4),' ',Chr(5),' ',Chr(6),' ',Chr(14));
  209.      GotoXY(3,6);
  210.      TextColor(7);
  211.      Write('A S D F G H J K L');
  212.      GotoXY(3,5);
  213.      TextColor(15);
  214.      Write(Chr(15),' ',Chr(16),' ',Chr(17),' ',Chr(18),' ',Chr(19),' ',Chr(20),' ',Chr(21),' ',Chr(22),' ',Chr(23));
  215.      GotoXY(3,8);
  216.      TextColor(7);
  217.      Write('Z X C V B N M ,');
  218.      GotoXY(3,7);
  219.      TextColor(15);
  220.      Write(Chr(24),' ',Chr(25),' ',Chr(26),' ',Chr(27),' ',Chr(28),' ',Chr(29),' ',Chr(30),' ',Chr(31));
  221.      GotoXY(40,3);
  222.      Write('Note: Use of any other');
  223.      GotoXY(40,4);
  224.      Write('key will return a space.');
  225.      Window2;
  226. end;
  227.  
  228.  
  229. procedure SpecialCase;
  230. begin
  231.      Case InkeyHold of
  232.       44 : InkeyHold := 31;
  233.       97 : InkeyHold := 15;
  234.       98 : InkeyHold := 28;
  235.       99 : InkeyHold := 26;
  236.      100 : InkeyHold := 17;
  237.      101 : InkeyHold := 3;
  238.      102 : InkeyHold := 18;
  239.      103 : InkeyHold := 19;
  240.      104 : InkeyHold := 20;
  241.      106 : InkeyHold := 21;
  242.      107 : InkeyHold := 22;
  243.      108 : InkeyHold := 23;
  244.      109 : InkeyHold := 30;
  245.      110 : InkeyHold := 29;
  246.      113 : InkeyHold := 1;
  247.      114 : InkeyHold := 4;
  248.      115 : InkeyHold := 16;
  249.      116 : InkeyHold := 5;
  250.      117 : InkeyHold := 14;
  251.      118 : InkeyHold := 27;
  252.      119 : InkeyHold := 2;
  253.      120 : InkeyHold := 25;
  254.      121 : InkeyHold := 6;
  255.      122 : InkeyHold := 24;
  256.      else
  257.      InkeyHold := 32;
  258.      Sound(200);
  259.      Delay(50);
  260.      NoSound;
  261.      end;
  262. end;
  263.  
  264. procedure KeysDisplay;
  265. begin
  266.      case Keyset of
  267.      1 : Keyset1;
  268.      2 : Keyset2;
  269.      3 : Keyset3;
  270.      4 : Keyset4;
  271.      end;
  272. end;
  273.  
  274. procedure PrintWords;
  275. begin
  276.     Window2;
  277.     TextColor(15);
  278.     ClrScr;
  279.     for i := 1 to 9 do begin
  280.        if Words[i] = Test then writeln else writeln(Words[i]);
  281.     end;
  282.     write(Words[10]);
  283. end;
  284.  
  285. function Replicate ( Count, Ascii : Integer ) : TempString;
  286. var
  287.   Temp : TempString;
  288.    I   : Byte;
  289.  
  290. Begin
  291.   Temp := '';
  292.   For I := 1 to Count do
  293.     Temp := Temp + chr(Ascii);
  294.   Replicate := Temp;
  295. end;
  296.  
  297. procedure ClearBuf;
  298. var dummy : char;
  299. begin
  300.    while KeyPressed do read(Kbd, dummy);
  301. end;
  302.  
  303. procedure Data_In(Line : integer;Var FileName : TempString);
  304. var
  305.    count, Maxcount : integer;
  306.    Letter : char;
  307.    NoGood, NameSet, ValidLetters, LowerCase : set of char;
  308.  
  309. begin
  310.    FileName := '--------.---';
  311.    count := 1;
  312.    ValidLetters := ['!'..'~'];
  313.    LowerCase := ['a'..'z'];
  314.    NoGood := ['*','<'..'?','[',']',' ','.'];
  315.    NameSet := ValidLetters - NoGood;
  316.    GotoXY(1,Line);
  317.    write(FileName);
  318.    GotoXY(1,Line);
  319.    Maxcount := Length(FileName);
  320.    repeat
  321.      GotoXY(count,Line);
  322.      read(Kbd, Letter);
  323.      if Letter in Lowercase then Letter := UpCase(Letter);
  324.      if (Letter = ' ') or (Letter = '.') then count := maxcount - 3;
  325.      if Letter in NameSet
  326.         then begin
  327.            FileName[count] := Letter;
  328.            GotoXY(1,Line);
  329.            Write(FileName);
  330.            count := count + 1;
  331.         end
  332.      else
  333.        if Letter = chr(8) then begin
  334.           if count = Pos('.',FileName) + 1 then count := count - 2
  335.              else count := count - 1;
  336.           if count < 1 then count := 1;
  337.           FileName[count] := '-';
  338.           GotoXY(1,Line);
  339.           write(FileName);
  340.         end
  341.      else if (Letter <> ' ') and (Letter <> chr(13)) and (ord(Letter) <> 27)
  342.         and (Letter <> '.') then write(chr(7));
  343.      if count = Pos('.',FileName) then count := count + 1;
  344.   until (count = Maxcount + 1) or (Letter = chr(13)) or (ord(Letter) = 27);
  345.   if (ord(Letter) = 27) or (count=1) then Exit := true else begin
  346.      if Copy(Filename, Maxcount-2,1) = '-' then begin
  347.         Filename := Copy(Filename, 1, Length(Filename)-4);
  348.         Filename := Filename + '.FIL';
  349.      end;
  350.      repeat
  351.         Delete(Filename,Pos('-',Filename),1);
  352.      until Pos('-',Filename)=0;
  353.      GotoXY(1,Line);
  354.      Write('                ');
  355.      GotoXY(1,Line);
  356.      Write(Filename);
  357.   end;
  358. end;
  359.  
  360. procedure Initialize;
  361.  begin
  362.     CrtInit;
  363.     GotoXY(1,25);
  364.     TextColor(0);
  365.     TextBackground(7);
  366.     write('Keyset 1 ':10,'Keyset 2 ':10,'Keyset 3 ':10,'Keyset 4 ':10,'Exit ':6);
  367.     write('InsLine':8,'DelLine':8,'Print':6,'Load':5,'Save':5);
  368.     TextColor(7);
  369.     TextBackground(0);
  370.     for i := 1 to 10 do begin
  371.        GotoXY(Positions[i], 25);
  372.        write(Digits[i]);
  373.      end;
  374.     Window2;
  375.     Row := 1;
  376.     Column := 1;
  377.     ScreenRow := 1;
  378.     MaxRow := 1;
  379.     TempWord := Replicate(65,32);
  380.     Test := TempWord;
  381.     for i := 1 to 500 do Words[i] := TempWord;
  382.     TempWord := '';
  383.     Exit := false;
  384.     NumEnd := 1;
  385.     Keyset := 1;
  386. end;
  387.  
  388. procedure Printrow;
  389. begin
  390.    Window1;
  391.    TextColor(7);
  392.    GotoXY(43,1);
  393.    writeln('LINE: ',Row : 3,'  COLUMN:  ',Column : 2);
  394.    TextColor(15);
  395.    Window2;
  396. end;
  397.  
  398.  
  399.  
  400. procedure ClearScreen;
  401. begin
  402.    Temp1 := Row;
  403.    Temp2 := ScreenRow;
  404.    Temp3 := Column;
  405.    Window3;
  406.    ClrScr;
  407.    GotoXY(1,3);
  408.    write('Clear Memory, Erase  Text?');
  409.    writeln;
  410.    writeln;
  411.    write('ARE YOU SURE? (Y/N) ');
  412.    read(Kbd,Inkey);
  413.    write(Inkey);
  414.    if (Inkey = 'y') or (Inkey = 'Y') then begin
  415.         TempWord := Replicate(65,32);
  416.         for i := 1 to 500 do Words[i] := TempWord;
  417.         Row := 1;
  418.         ScreenRow := 1;
  419.         Column := 1;
  420.         MaxRow := 1;
  421.      end
  422.    else begin
  423.        Exit := true;
  424.        Row := Temp1;
  425.        ScreenRow := Temp2;
  426.        Column := Temp3;
  427.    end;
  428.    Window2;
  429. end;
  430.  
  431.  
  432. function GetKey(var secnum : boolean; var Inkey : char) : boolean;
  433. begin
  434.    if KeyPressed then begin
  435.       result := true;
  436.       dosrec.ax := $0800;
  437.       msdos(dosrec);
  438.       Inkey := chr(lo(dosrec.ax));
  439.       InkeyHold := lo(dosrec.ax);
  440.       Secnum := ord(Inkey) = 0;
  441.       if Secnum then begin
  442.          dosrec.ax := $0800;
  443.          msdos(dosrec);
  444.          Keynum := ord(chr(lo(dosrec.ax)));
  445.       end
  446.       else if ord(Inkey) <= 27 then begin
  447.          Secnum := true;
  448.          Keynum := ord(Inkey);
  449.       end
  450.       else begin
  451.          Keynum := ord(Inkey);
  452.          Secnum := false;
  453.       end
  454.    end
  455.    else begin
  456.       Getkey := false;
  457.       secnum := false;
  458.    end;
  459. end;
  460.  
  461. procedure WordWrap;
  462. var SpacePosition : integer;
  463.  
  464. begin
  465.    TextColor(15);
  466.    SpacePosition := 65;
  467.    TempWord := Words[Row];
  468.    Sound(400);
  469.    Delay(20);
  470.    NoSound;
  471.    case Keyset of
  472.    1 : InkeyHold := InkeyHold;
  473.    2 : InkeyHold := InkeyHold + 64;
  474.    3 : InkeyHold := InkeyHold + 128;
  475.    4 : SpecialCase;
  476.    end;
  477.    If InkeyHold = 127 then InkeyHold := 0;
  478.    If Inkey = Chr(32) then Inkey := Chr(32) else Inkey := Chr(InkeyHold);
  479.    repeat
  480.       SpacePosition := SpacePosition - 1;
  481.    until TempWord[SpacePosition] = ' ';
  482.    if SpacePosition < 2 then SpacePosition := 2;
  483.    Words[Row+1] := Copy(Words[Row], SpacePosition + 1, 65-(SpacePosition+1)) +
  484.                     Inkey + Copy(Words[Row+1], 1, SpacePosition - 2);
  485.    Words[Row] := Copy(Words[Row], 1, SpacePosition - 1) + Replicate(66 - SpacePosition, 32);
  486.    ScreenRow := ScreenRow + 1;
  487.    if ScreenRow > 10 then begin
  488.      ScreenRow := 10;
  489.      GotoXY(1,1);
  490.      DelLine;
  491.      GotoXY(1, ScreenRow-1);
  492.      writeln(Words[Row]);
  493.      write(Words[Row+1]);
  494.     end
  495.    else begin
  496.       GotoXY(1, ScreenRow-1);
  497.       writeln(words[Row]);
  498.       write(Words[Row+1]);
  499.      end;
  500.    Row := Row + 1;
  501.    if Row > MaxRow then MaxRow := Row;
  502.    Column := Length(Words[Row])- SpacePosition + 3;
  503. end;
  504.  
  505. procedure Character;
  506. begin
  507.    TextColor(15);
  508.    if Column = 65 then WordWrap else begin
  509.    case Keyset of
  510.    1 : InkeyHold := InkeyHold;
  511.    2 : InkeyHold := InkeyHold + 64;
  512.    3 : InkeyHold := InkeyHold + 128;
  513.    4 : SpecialCase;
  514.    end;
  515.    If InkeyHold = 127 then InkeyHold := 0;
  516.    If Inkey = Chr(32) then Inkey := Chr(32) else
  517.    Inkey := Chr(InkeyHold);
  518.    begin
  519.       GotoXY(Column,ScreenRow);
  520.       write(Inkey);
  521.       Insert(Inkey, Words[Row], Column);
  522.       if not Insertmode then Delete(Words[Row],Column + 1,1);
  523.       Column := Column + 1;
  524.    end;
  525.  end;
  526. end;
  527.  
  528. procedure Del;
  529.   begin
  530.     TextColor(15);
  531.     ch := Copy(Words[Row], Column, 1);
  532.     Delete(Words[Row], Column, 1);
  533.     Words[Row] := Words[Row] + ' ';
  534.     GotoXY(1, ScreenRow);
  535.     if ScreenRow = 10 then write(Words[Row]) else writeln(Words[Row]);
  536.   end;
  537.  
  538. procedure Backspace;
  539.   begin
  540.     if Column > 1 then begin
  541.        Column := Column - 1;
  542.        Del;
  543.     end;
  544.  end;
  545.  
  546. procedure InsertLine;
  547. begin
  548.    InsLine;
  549.    for i := MaxRow + 1 downto Row do Words[i+1] := Words[i];
  550.    Words[Row] := Replicate(65,32);
  551.    MaxRow := MaxRow + 1;
  552. end;
  553.  
  554. procedure Enter;
  555. begin
  556.   TextColor(15);
  557.   column := 1;
  558.   row := row + 1;
  559.   if row > MaxRow then MaxRow := Row;
  560.   ScreenRow := Screenrow + 1;
  561.   if ScreenRow > 10 then begin
  562.      GotoXY(1,1);
  563.      DelLine;
  564.      ScreenRow := 10;
  565.      GotoXY(1, ScreenRow);
  566.      write(Words[Row]);
  567.   end;
  568.   GotoXY(Column, Screenrow);
  569.   if InsertMode then InsertLine;
  570. end;
  571.  
  572. procedure CursorLeft;
  573. begin
  574.   column := column - 1;
  575.   if column < 1 then begin
  576.      column := 65;
  577.      if Row = 1 then Row := 1 else Row := Row - 1;
  578.      if ScreenRow = 1 then ScreenRow := 1 else ScreenRow := ScreenRow - 1;
  579.      end
  580. end;
  581.  
  582. procedure CursorRight;
  583. begin
  584.   TextColor(15);
  585.   column := column + 1;
  586.   If Column > 65 then begin
  587.   Column := 1;
  588.   Row := Row + 1;
  589.   if Row > MaxRow then MaxRow := Row;
  590.   If ScreenRow < 10 then ScreenRow := ScreenRow + 1 else begin
  591.      ScreenRow := 10;
  592.      GotoXY(1,1);
  593.      DelLine;
  594.      GotoXY(1, ScreenRow);
  595.      write(Words[Row]);
  596.     end;
  597.   end;
  598. end;
  599.  
  600. procedure CursorUp;
  601. var Count : integer;
  602. begin
  603.    TextColor(15);
  604.    if row = 1 then Row_One := true else Row_One := false;
  605.    row := row - 1;
  606.    if row < 1 then row := 1;
  607.    if (ScreenRow = 1) and not Row_One then begin
  608.        GotoXY(1,1);
  609.        InsLine;
  610.        GotoXY(1,1);
  611.        write(Words[Row]);
  612.    end;
  613.    ScreenRow := ScreenRow - 1;
  614.    if ScreenRow < 1 then ScreenRow := 1;
  615. end;
  616.  
  617. procedure CursorDown;
  618. begin
  619.   TextColor(15);
  620.   row := row + 1;
  621.   if row > MaxRow then MaxRow := Row;
  622.   ScreenRow := ScreenRow + 1;
  623.   if ScreenRow > 10 then begin
  624.      ScreenRow := 10;
  625.      GotoXY(1,1);
  626.      DelLine;
  627.      GotoXY(1, ScreenRow);
  628.      write(Words[Row]);
  629.   end;
  630. end;
  631.  
  632. procedure Ins;
  633. begin
  634.   TextColor(7);
  635.   if Insertmode then Insertmode := false
  636.     else Insertmode := true;
  637.   Window1;
  638.   GotoXY(1,1);
  639.   if Insertmode = true then write('Insert') else write('      ');
  640.   TextColor(15);
  641. end;
  642.  
  643. procedure Warning;
  644.  
  645. begin
  646.    ClrScr;
  647.    Writeln(chr(7),'--------------  ');
  648.    writeln('That file already');
  649.    writeln('    exists.');
  650.    writeln;
  651.    writeln('Replace it (Y/N)?');
  652.    writeln;
  653.    writeln('---------------');
  654.    GotoXY(19,6);
  655.    Read(Kbd, Choice);
  656.    GotoXY(19,6);
  657.    write(Choice);
  658.    if (Choice = 'n') or (Choice = 'N') then Exit := true;
  659.    ClrScr;
  660. end;
  661.  
  662. procedure Savefile;
  663. var Exist : boolean;
  664.  
  665. begin
  666.    Temp1 := Row;
  667.    Temp2 := ScreenRow;
  668.    Temp3 := Column;
  669.    Window3;
  670.    ClrScr;
  671.    GotoXY(1,5);
  672.    writeln('Enter File Name:');
  673.    write('Default = .FIL');
  674.    GotoXY(1,10);
  675.    write('Press Esc to exit');
  676.    Data_In(8, Filename);
  677.    if Exit = false then begin
  678.       GotoXY(1,10);
  679.       Assign(TextFile, Filename);
  680.       {$I-}
  681.       Reset(TextFile);
  682.       {$I+}
  683.       Exist := (IOresult = 0);
  684.       if Exist = true then Warning;
  685.       if Exit = false then begin
  686.          Rewrite(TextFile);
  687.          Row := 1;
  688.          for i := 1 to MaxRow + 1 do begin
  689.             Writeln(TextFile, Words[Row]);
  690.             Row := Row + 1;
  691.          end;
  692.          Close(TextFile);
  693.       end;
  694.    end;
  695.    KeysDisplay;
  696.    Window2;
  697.    Row := Temp1;
  698.    ScreenRow := Temp2;
  699.    Column := Temp3;
  700. end;
  701.  
  702. procedure Loadfile;
  703. var  Exist : boolean;
  704.  
  705. begin
  706.    Temp1 := Row;
  707.    Temp2 := ScreenRow;
  708.    Temp3 := Column;
  709.    Window3;
  710.    ClrScr;
  711.    GotoXY(1,5);
  712.    writeln('Enter File Name:');
  713.    write('Default = .FIL');
  714.    GotoXY(1,10);
  715.    write('Press Esc to exit');
  716.    Data_In(8, Filename);
  717.    if Exit = false then begin
  718.       GotoXY(1,10);
  719.       Assign(TextFile, Filename);
  720.       {$I-}
  721.       Reset(TextFile);
  722.       {$I+}
  723.       Exist := (IOresult = 0);
  724.       if Exist = true then begin
  725.          TempWord := Test;
  726.          ClearScreen;
  727.          if Exit = false then begin
  728.             While EOF(Textfile) = false do begin
  729.                Readln(TextFile, Words[Row]);
  730.                if Length(Words[Row]) >= 66 then Words[Row] := Copy(Words[Row], 1, 79);
  731.                Row := Row + 1;
  732.                end;
  733.             Close(TextFile);
  734.             MaxRow := Row + 1;
  735.             Window2;
  736.             ClrScr;
  737.             GotoXY(1,1);
  738.             PrintWords;
  739.             Row := 1;
  740.             Column := 1;
  741.             ScreenRow := 1;
  742.          end;
  743.       end;
  744.       if Exist=false then begin
  745.          ClrScr;
  746.          writeln(chr(7));
  747.          writeln('File does not exist');
  748.          Delay(1000);
  749.          Exit := true;
  750.       end;
  751.    end;
  752.    if Exit = true then begin
  753.       Row := Temp1;
  754.       ScreenRow := Temp2;
  755.       Column := Temp3;
  756.    end;
  757.    KeysDisplay;
  758.    Window2;
  759. end;
  760.  
  761. procedure PrintFile;
  762. var lines, Linespaces, j : integer;
  763.  
  764. begin
  765.    Temp1 := Row;
  766.    Temp2 := ScreenRow;
  767.    Temp3 := Column;
  768.    Window3;
  769.    ClrScr;
  770.    GotoXY(1,7);
  771.    writeln('Press any key...');
  772.    Read(Kbd,Ch);
  773.    ClrScr;
  774.    GotoXY(1,3);
  775.    TextColor(White + Blink);
  776.    writeln('Printing...');
  777.    TextColor(White);
  778.    writeln;
  779.    writeln(' Press any key ');
  780.    writeln(' to abort.     ');
  781.    i := 0;
  782.    Test := Replicate(65,32);
  783.    While (not KeyPressed) and (i < MaxRow + 1) do begin
  784.          TempWord := Test;
  785.          i := i + 1;
  786.          TempWord := Words[i];
  787.          Index := 0;
  788.          if TempWord = Test then write(Lst, chr(10)) else
  789.                begin
  790.                repeat
  791.                   Index := Index + 1;
  792.                   Write(Lst, TempWord[Index]);
  793.                until Index >= 65;
  794.                Write(Lst,Chr(10));
  795.                end;
  796.    end;
  797.    write(lst,chr(12));
  798.    Window2;
  799.    Row := Temp1;
  800.    ScreenRow := Temp2;
  801.    Column := Temp3;
  802.    KeysDisplay;
  803. end;
  804.  
  805.  
  806.  
  807. procedure DeleteLine;
  808. begin
  809.    TextColor(15);
  810.    DelLine;
  811.    if MaxRow > Row + (11-ScreenRow) then begin
  812.       GotoXY(1, 10);
  813.       write(Words[Row+(11-ScreenRow)]);
  814.    end;
  815.    for i := Row to MaxRow + 1 do Words[i] := Words[i+1];
  816.    MaxRow := MaxRow - 1;
  817.    if Row > MaxRow then MaxRow := Row;
  818. end;
  819.  
  820.  
  821.  
  822. procedure Tab;
  823. begin
  824.    if Column < 65 then begin
  825.       repeat
  826.         Column := Column + 1;
  827.       until (Tabset[Column] = true) or (Column = 65);
  828.    end;
  829. end;
  830.  
  831.  
  832.  
  833. procedure Esc;
  834. begin
  835.    Column := 1;
  836.    GotoXY(1, WhereY);
  837.    ClrEol;
  838.    Words[Row] := Replicate(79,32);
  839. end;
  840.  
  841.  
  842.  
  843. procedure DrawScreen;
  844. begin
  845.      ClrScr;
  846.      Window1;
  847.      ClrScr;
  848.      TextColor(7);
  849.      GotoXY(1,2);
  850.      Write(Replicate(65,250));
  851.      for i := 1 to 65 do Tabset[i] := False;
  852.      for i := 1 to 12 do
  853.      begin
  854.           GotoXY(TabPositions[i],2);
  855.           Write(Chr(31));
  856.           Tabset[TabPositions[i]] := True;
  857.      end;
  858.      GotoXY(65,2);
  859.      Write(Chr(174));
  860.      Window(1,1,80,25);
  861.      GotoXY(1,13);
  862.      Write(Chr(201));
  863.      Write(Replicate(78,205));
  864.      Write(Chr(187));
  865.      for i := 14 to 23 do
  866.      begin
  867.           GotoXY(1,i);
  868.           Write(Chr(186));
  869.           GotoXY(80,i);
  870.           Write(Chr(186));
  871.      end;
  872.      GotoXY(1,24);
  873.      Write(Chr(200));
  874.      Write(Replicate(78,205));
  875.      Write(Chr(188));
  876. end;
  877.  
  878.  
  879.  
  880.  
  881. procedure HandleFunc;
  882.   begin
  883.      case Keynum of
  884.         8 : Backspace;
  885.         9 : Tab;
  886.        13 : Enter;
  887.        27 : Esc;
  888.        59 : begin
  889.             KeySet := 1;
  890.             KeysDisplay;
  891.             end;
  892.        60 : begin
  893.             KeySet := 2;
  894.             KeysDisplay;
  895.             end;
  896.        61 : begin
  897.             Keyset := 3;
  898.             KeysDisplay;
  899.             end;
  900.        62 : begin
  901.             KeySet := 4;
  902.             KeysDisplay;
  903.             end;
  904.        63 : begin
  905.             Savefile;
  906.             NumEnd := 9999;
  907.             end;
  908.        64 : Insertline;
  909.        65 : Deleteline;
  910.        66 : Printfile;
  911.        67 : Loadfile;
  912.        68 : Savefile;
  913.        72 : CursorUp;
  914.        75 : CursorLeft;
  915.        77 : CursorRight;
  916.        80 : CursorDown;
  917.        82 : Ins;
  918.        83 : Del;
  919.     else
  920.       Sound(250);
  921.       Delay(600);
  922.       NoSound;
  923.     end;
  924.   end;
  925.  
  926. begin
  927.   Initialize;
  928.   DrawScreen;
  929.   PrintRow;
  930.   KeysDisplay;
  931.   GotoXY(1,1);
  932.   repeat
  933.     Secnum := false;
  934.     if Getkey(Secnum, Inkey) then begin
  935.        if Secnum then HandleFunc else Character;
  936.        PrintRow;
  937.        TextColor(15);
  938.        Exit := false;
  939.        if Length(Words[Row]) > 65 then Words[Row] := Copy(Words[Row], 1, 65);
  940.        if Insertmode then begin
  941.          GotoXY(1, ScreenRow);
  942.          if ScreenRow = 10 then write(Words[Row]) else writeln(Words[Row]);
  943.        end;
  944.        GotoXY(Column , ScreenRow);
  945.     end;
  946.     if IOresult <> 0 then NumEnd := 9999;
  947.   until NumEnd = 9999;
  948.   Window(1,1,80,25);
  949.   ClrScr;
  950. end.
  951.